﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace JJMent.EFCore.Migrations
{
    public partial class JJMent1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ProductType",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductTypeName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductType", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Product",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ProductmMterial = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Price = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    MarketValue = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Brand = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Colour = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ProductTypeId = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Product", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Product_ProductType_ProductTypeId",
                        column: x => x.ProductTypeId,
                        principalTable: "ProductType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.InsertData(
                table: "ProductType",
                columns: new[] { "Id", "ProductTypeName" },
                values: new object[,]
                {
                    { 1, "椅子" },
                    { 2, "餐桌" },
                    { 3, "沙发" },
                    { 4, "创意" }
                });

            migrationBuilder.InsertData(
                table: "Product",
                columns: new[] { "Id", "Brand", "Colour", "MarketValue", "Price", "ProductName", "ProductTypeId", "ProductmMterial" },
                values: new object[,]
                {
                    { 1, "自制", "红", "250", "230", "牛皮单人软椅", 1, "牛皮,桐木" },
                    { 2, "自制", "红", "450", "430", "貂皮单人软椅", 1, "貂皮,桐木" },
                    { 3, "自制", "红", "450", "400", "牛皮三人软椅", 1, "牛皮,桐木" },
                    { 4, "自制", "银", "450", "400", "三人不锈钢餐桌", 2, "不锈钢" },
                    { 5, "自制", "红", "550", "500", "三人桐木餐桌", 2, "桐木" },
                    { 6, "自制", "红", "650", "600", "八人桐木餐桌", 2, "桐木" },
                    { 7, "自制", "红", "750", "700", "八人不锈钢餐桌", 2, "不锈钢" }
                });

            migrationBuilder.CreateIndex(
                name: "IX_Product_ProductTypeId",
                table: "Product",
                column: "ProductTypeId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Product");

            migrationBuilder.DropTable(
                name: "ProductType");
        }
    }
}
